<!-- 页面-简介 -->
<template>
  <BaseForm
    style="width: 500px"
    :fetch="PostMockCommon"
    :fields="fields"
    :moreBtns="[
      { name: 'pass', popconfirm: false },
      { name: 'view', text: '查看' },
    ]"
    @moreBtns="onMoreBtns"
  ></BaseForm>
</template>
<script lang="ts" setup>
import { CommonObj, FinallyNext } from "@/_types";
import { PostMockCommon } from "@/api-mock";
import { FormField } from "@/components/form/_types";
import { BtnName } from "@/components/BaseBtn/_types";
import { handleBtnNext } from "~/utils";
import { usePopup } from "~/hooks";

const { openPopup } = usePopup();

const props = withDefaults(
  defineProps<{
    exampleProp?: CommonObj;
  }>(),
  { exampleProp: () => ({}) }
);
const fields: FormField[] = [
  { prop: "tx", label: "头像", type: "BaseUpload" },
  {
    tpl: "T_Phone",
    prop: "dhhm",
    label: "电话号码",
    required: true,
    quickAttrs: {},
  },
  {
    prop: "xm",
    label: "姓名",
    quickAttrs: {
      explain: "请注意输入真实姓名",
    },
    attrs: {
      maxlength: 6,
    },
  },
  {
    prop: "zwjs",
    label: "自我介绍",
    attrs: {
      type: "textarea",
      maxlength: 100,
      rows: 3,
    },
  },
];
function onMoreBtns(name: BtnName, data: CommonObj, next: FinallyNext) {
  handleBtnNext(
    {
      pass: () => PostMockCommon().then(() => next()),
      view: () => openPopup("第二个纯文本弹窗示例", "你好！这是第二个纯文本弹窗示例"),
    },
    name
  );
}
</script>
<style lang="scss" scoped></style>
